<template>
  <div></div>
</template>

<script setup lang="ts">
  // localStorage
  // 基本使用

  // 设置值
  localStorage.setItem('name', 'kunkun')

  // 获取值
  let username = localStorage.getItem('name')
  console.log(username)

  // 删除值
  // localStorage.removeItem('name')

  // 移除所有值
  // localStorage.clear()

  let key = localStorage.key(0)

  console.log(key)

  // SessionStorage
  // 基本使用

  // 设置值
  sessionStorage.setItem('nikname', 'ikun')
  // 获取值
  sessionStorage.getItem('nikname')
  // 删除值
  sessionStorage.removeItem('nikname')
  // 清空所有值
  sessionStorage.clear()

  // cookie
  // 获取 cookie
  let cookie = document.cookie
  // 设置 cookie
  document.cookie = 'name=kunkun'
  document.cookie = 'age=18'

  console.log(cookie) // name=kunkun; age=18
  // 删除 cookie
  document.cookie = 'age=18; expires=' + new Date(0).toUTCString()
</script>

<style scoped></style>
